package com.fer.andenginemvc.api;

import java.util.HashMap;

import org.andengine.ui.activity.SimpleBaseGameActivity;

public abstract class SceneManager<T extends SimpleBaseGameActivity> extends HashMap<String, Controller<T>>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8019082510179532480L;
	protected T baseActivity;
	
	private Controller<T> currentController;
	
	public SceneManager(T baseActivity) {
		super();
		this.baseActivity = baseActivity;
		registerAllControllers();
		
	}
	
	@Override
	public Controller<T> get(Object key) {
		if (currentController != null)
		{
			currentController.onLeave();
		}
		Controller<T> controller =  super.get(key);
		controller.onShow();
		currentController = controller;
		return controller;
	}
	
	public abstract void registerAllControllers();
}
